<form id="roleseditfm" method="post" style="padding: 8px;">
    <input type="hidden" name="id" value="<?php echo $dataset->id;?>"/>
    <table border="0" width="100%" cellspacing="1" cellpadding="5" class="formtable">
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" width="20%">角色名：</td>
            <td width="80%"><input name="name" type="text" value="<?php echo $dataset->name;?>" style="width:400px;" class="forminput inputstyle textbox-text validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入角色名.." required="true"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" width="20%">权限组：</td>
            <td width="80%">
                <ul id="roleseditMenu" name="menu_ids"></ul>
                <input type="hidden" name="menu_ids" id="rolesedit_menu_ids"/>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" width="20%">排序：</td>
            <td width="80%"><input name="sortorder" type="text" value="<?php echo $dataset->sortorder;?>" class="forminput inputstyle textbox-text validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入排序.."></td>
        </tr>
    </table>
</form>

<script>
    $('#roleseditMenu').tree({
        data: JSON.parse('<?php echo json_encode($menus);?>'),
        checkbox: true,
        lines: true,
        //onlyLeafCheck: true,
    });
    $(function () {
        $('#rolesupdatesubmit').click(function (data) {
			$('#rolesedit_menu_ids').val(getTreeChecked('#roleseditMenu'));
            $('#roleseditfm').form('submit', {
                url: '/admin/system/rolesedit',
                success: function (data) {
                    var data = eval('(' + data + ')');

                    if (data.ret == 0) {
                        $.messager.show({
                            title: '提示',
                            msg: data.msg,
                            timeout: 3000,
                            showType: 'slide'
                        });
                        $('#roleseditfm').form('clear');
                        $("#rolesdlg").dialog('close');
                        $("#roles").datagrid('reload');
                    } else {
                        var msginfo = '';
                        if (data.data != '') {
                            var n = 1;
                            $.each(data.data, function (k, v) {
                                msginfo += n + '.' + v + '<br>';
                                n++;
                            });
                        }
                        $.messager.alert('提示', data.msg + '<br>' + msginfo, 'warning');
                    }
                }
            });
        });
    });
</script>
